package com.sxj.corejava.code08_常用类.日期类;

import java.util.Date;

/**
 * @author 石小俊
 * @date 2025年01月11日
 */
public class Test02_常用方法 {

    public static void main(String[] args) {
        // 当天
        Date date = new Date();
        System.out.println(date);
        long time = date.getTime();
        long time2 = System.currentTimeMillis();
        System.out.println(time);
        System.out.println(time2);

        // 昨天
        Date date2 = new Date(time - 24 * 60 * 60 * 1000);
        System.out.println(date2);

        System.out.println(date.after(date2));
        System.out.println(date.before(date2));

        // 大于返回1,等于返回0,小于返回-1
        System.out.println(date.compareTo(date2));
        System.out.println(date2.compareTo(date));
        System.out.println(date.compareTo(date));

    }

}
